--[[
适合自动追击的投射物，只会对没有buff的单位释放
伤害间隔为目标buff时间，
]]
local mt = ac.skill['凤凰火焰']
mt.art = [[ReplaceableTextures\CommandButtons\BTNMarkOfFire.blp]]
mt.skill_type = 'passive'
mt.area = 600           --索敌范围 设置为0为单位的攻击距离
mt.cool = 0.5           --触发冷却
mt.damage = 100         --造成伤害
mt.damage_type = '魔法' --伤害类型
mt.damage_cool = 1      --每个伤害单位间隔
--弹道模型
mt.missile_art = [[Abilities\Weapons\PhoenixMissile\Phoenix_Missile_mini.mdl]]
mt.missile_arc = 0       --弹道弧度
mt.missile_speed = 900   --弹道速度

function mt:on_add()
    local hero = self.owner
    self:gc(ac.loop(self.cool*1000,function()
        if hero:is_alive() and self:is_enable() then
            self:shot()
        end
    end))
end

function mt:shot(target)
    local hero = self.owner
    local target = target or ac.selector('unit'):range(hero,self.area):enemy(hero):filter(function(unit)
        return not hero:find_buff '凤凰火焰'
    end):random()
    if not target then
        return
    end
    ac.mover('target'){
        start = hero:get_launch_point(),
        target = target,
        model = self.missile_art,
        arc = self.missile_arc,
        speed = self.missile_speed,
        on_run = function()
            target:add_buff '凤凰火焰'{time = self.damage_cool}
            hero:create_damage(target,self.damage,'魔法',self)
            self:notify('on_run',target)
        end
    }
end

local buff = ac.buff['凤凰火焰']
mt.art = [[ReplaceableTextures\CommandButtons\BTNMarkOfFire.blp]]
